package com.dks.repository.impl;

import com.dks.mapper.TalksRecordMapper;
import com.dks.mapper.TextDetailMapper;
import com.dks.mapper.TimesMapper;
import com.dks.models.TalksRecord;
import com.dks.models.TextDetail;
import com.dks.models.Times;
import com.dks.repository.ITextDetailRepository;
import com.dks.repository.ITimesRepository;
import com.dks.result.ResultModel;
import com.dks.util.Commond;
import com.dks.util.PageInfo;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Repository
public class TextDetailRepository implements ITextDetailRepository {

    @Resource
    private TextDetailMapper textDetailMapper;

    @Override
    public ResultModel<Boolean> insert(TextDetail TextDetail) {
        int row = textDetailMapper.insert(TextDetail);
        ResultModel resultModel = new ResultModel();
        if (1 == row) {
            resultModel.setCode(Commond.CODE_SUCCESS);
            resultModel.setMessage(Commond.MSG_SUCCESS);
            resultModel.setData(row);
        } else {
            resultModel.setCode(Commond.CODE_FAIL);
            resultModel.setMessage(Commond.MSG_FALE);
            resultModel.setData(row);
        }
        return resultModel;
    }

    @Override
    public ResultModel<Boolean> update(TextDetail TextDetail) {
        int row = textDetailMapper.update(TextDetail);
        ResultModel resultModel = new ResultModel();
        if (1 == row) {
            resultModel.setCode(Commond.CODE_SUCCESS);
            resultModel.setMessage(Commond.MSG_SUCCESS);
            resultModel.setData(row);
        } else {
            resultModel.setCode(Commond.CODE_FAIL);
            resultModel.setMessage(Commond.MSG_FALE);
            resultModel.setData(row);
        }
        return resultModel;
    }

    @Override
    public ResultModel selectByType(Integer type) {
        TextDetail textDetail = textDetailMapper.selectByType(type);
        ResultModel resultModel = new ResultModel();
        resultModel.setCode(Commond.CODE_SUCCESS);
        resultModel.setMessage(Commond.MSG_SUCCESS);
        resultModel.setData(textDetail);
        return resultModel;
    }
}
